package com.basic.demo.controller;

import com.basic.demo.domain.Demo;
import com.basic.demo.exception.BusinessException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

    @RequestMapping(value = "/demo/{id}", method = RequestMethod.GET)
    public Demo findById(@PathVariable long id) {
        Demo demo = null;
        if (demo == null) {
            throw new BusinessException();
        }
        return demo;
    }


    /*@ExceptionHandler(BusinessException.class)
    @ResponseStatus(HttpStatus.NOT_FOUND)
    public Error spittleNotFound(BusinessException e) {
        System.out.println("异常处理中");
        //long spittleId = e.getSpittleId();
        // return new Error(4, "Spittle [" + spittleId + "] not found");
        return null;
    }*/
}